@(user: securesocial.core.BasicProfile)(implicit request: RequestHeader, env: securesocial.core.RuntimeEnvironment)

@import securesocial.core.AuthenticationMethod._

@main("SecureSocial - Sample Protected Page") {
<div class="page-header">
    <h2><img src="@user.avatarUrl.getOrElse("")" alt="@user.firstName.getOrElse("")" width="40px" height="40px"/> Welcome @user.firstName.getOrElse("")</h2>
</div>

<div class="clearfix">
    <h2>User Details</h2>

    <ul>
        <li>User Id: @user.userId</li>
        <li>Fist name: @user.firstName.getOrElse("")</li>
        <li>Last name: @user.lastName.</li>
        <li>Full name: @user.fullName.getOrElse("")</li>
        <li>Logged in from: @user.providerId</li>
        <li>Email: @user.email.map { email => @email }.getOrElse("Not Available")</li>
        <li>Authentication method: @user.authMethod</li>
    </ul>

    @user.oAuth1Info.map { info =>
        <h2>OAuth1 Info</h2>

        <ul>
            <li>Token: @info.token</li>
            <li>Secret: @info.secret</li>
        </ul>
    }

    @user.oAuth2Info.map { info =>
        <h2>OAuth2 Info</h2>

        <ul>
            <li>Access Token: @info.accessToken</li>
            @info.tokenType.map { t => <li>Token Type: @t</li> }
            @info.expiresIn.map { exp => <li>Expires in: @exp seconds</li>}
            @info.refreshToken.map { rt => <li>Refresh Token: @rt</li>}
        </ul>
    }
    <hr>
    @user.passwordInfo.map { info =>
        <a class="btn" href="@env.routes.passwordChangeUrl">Change Password</a>
    }

    <span>Link this account to

    @env.providers.values.map { provider =>
        @if( provider.authMethod == OAuth1 || provider.authMethod == OAuth2 ) {
            @defining( "images/providers/%s.png".format(provider.id) ) { imageUrl =>
            <a href="@env.routes.authenticationUrl(provider.id, Some("/link-result"))"> <img src="@securesocial.controllers.routes.Assets.at(imageUrl)"/></a>
            }
        }
    }
    </span>
    <hr>
    <a class="btn" href="@routes.Application.linkResult()">Linked Accounts</a>
    <a class="btn" href="@securesocial.controllers.routes.LoginPage.logout()">Logout</a>
</div>
}